//
//  WQStatusCell.swift
//  WeiBo
//
//  Created by 张德华 on 7/24/16.
//  Copyright © 2016 ZhangDeHua. All rights reserved.
//

import UIKit
import SnapKit


/**cell中使用的间距*/
let statusCellMargin: CGFloat = 10

class WQStatusCell: UITableViewCell {
    
    var toolBarBottomConstraint: Constraint?
  
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    
   
    var statusViewModel: WQStatusViewModel? {
        didSet {
        
            ///------ 给原创微博赋值
            originalView.statusViewModel = statusViewModel
            reweetView.statusViewModel = statusViewModel
            toolBarView.statusViewModel = statusViewModel
            
        }
    }
    
    
    
    
    
    
    func setupUI() {
        selectionStyle = UITableViewCellSelectionStyle.None
        ///------ 添加
        contentView.addSubview(originalView)
        contentView.addSubview(reweetView)
        contentView.addSubview(toolBarView)
        
        ///------ 约束
        originalView.snp_makeConstraints { (make) in
            make.top.leading.trailing.equalTo(contentView)
        }
        reweetView.snp_makeConstraints { (make) in
            make.top.equalTo(originalView.snp_bottom)
            make.leading.trailing.equalTo(contentView)
        }
        toolBarView.snp_makeConstraints { (make) in
            self.toolBarBottomConstraint = make.top.equalTo(reweetView.snp_bottom).constraint
            make.leading.trailing.equalTo(contentView)
            make.height.equalTo(30)
        }
        contentView.snp_makeConstraints { (make) in
            make.leading.trailing.top.equalTo(self)
            make.bottom.equalTo(toolBarView.snp_bottom)
        }
    }
    
    
    
    ///------ 懒加载
    lazy var originalView: WQStatusOriginalView = WQStatusOriginalView()
    lazy var reweetView: WQStatusRetweetView = WQStatusRetweetView()
    lazy var toolBarView: WQStatustoolBarView = WQStatustoolBarView()
}
